﻿@model Easy.CMS.List.ViewModel.ListViewModel
@using Easy.Web.CMS.Data
@{
    if(!Model.Widget.DetailPageUrl.IsNullOrEmpty())
    {
        Model.Widget.DetailPageUrl = Url.Content(Model.Widget.DetailPageUrl);
    }
}
<script>
    $(function() {
        var shortWidth = $(".media-list").width() -10;
        $(".shorttext").css("width", shortWidth + "px");
    })
</script>
<div class="list-list container-fluid">
    @if (!Model.JsonResult.IsNullOrEmpty() && Model.Columns!=null && Model.Columns.Count>0)
    {
        var data = Json.Decode(Model.JsonResult);

        <div class="row">
            <div class="col-sm-12">
                <ul class="media-list">
                     @foreach (var item in data)
                     {
                         string Id = item["Id"].ToString();
                         string content = !Model.Columns[1].IsNullOrEmpty() ? @item[Model.Columns[1]] : string.Empty;
                         <li class="media">
                            <div class="media-body">
                                <div class="media-heading">
                                    <a href="@Url.PathContent(Url.ListDetailUrl(Model.Widget.DetailPageUrl, Id))" target="_blank">
                                        @if (!Model.Columns[0].IsNullOrEmpty())
                                        {
                                             @item[Model.Columns[0]]
                                        }
                                    </a>
                                </div>
                                <div class="time_right_div">
                                    @content.ParseTags().GetSubString(180)
                                </div>
                            </div>
                        </li>
                     }
                </ul>
                @if(Model.IsPageable)
                {
                    Html.Pagin(Model.Pager);
                }
            </div>
        </div>
    }
</div>
